{extend name="../../admin/view/main"}

{block name="content"}

{include file='article/article/form_style'}

<form onsubmit="return false;" id=ArticleForm" data-auto="true" method="post" enctype="multipart/form-data" class='layui-form layui-card' autocomplete="off">

    <div class="layui-card-body think-box-shadow">
        <label class="layui-col-xs4 relative margin-left-10">
            <span class="color-green block">本页ID</span>
            {$vo.id|default=''}
        </label>

        <label class="layui-col-xs3 relative">
            <span class="color-green">所属栏目</span>
            <select Readonly="true" class="layui-select" name="cat_id">
                <option selected value="{$catInfo.id}">{$catInfo.title}</option>
            </select>
        </label>

        <div class="layui-form-item layui-row layui-col-space15">
            <label class="layui-col-xs9 relative">
                <span class="color-green">内容标题</span>
                <input name="title" required class="layui-input" placeholder="请输入内容标题" value="{$vo.title|default=''}">
            </label>
        </div>

        <div class="layui-form-item layui-row layui-col-space15">
            <label class="layui-col-xs12 relative">
                <span class="color-green">摘要</span>
                <textarea name="subtitle" class="layui-textarea"  placeholder="请输入摘要">{$vo.subtitle|default=''}</textarea>
            </label>
        </div>

        <div class="layui-form-item layui-row layui-col-space15">
            <label class="layui-col-xs9 relative">
                <span class="color-green">关键字</span>
                <input name="keywords" class="layui-input" placeholder="请输入关键字" value="{$vo.keywords|default=''}">
            </label>
        </div>

        <div class="layui-form-item">

            <table class="layui-table layui-col-xs6">
                <thead>
                <tr>
                    <th class="text-center">封面图</th>
                </tr>
                <tr>
                    <td width="90px" class="text-center"><input name="logo" type="hidden" value="{$vo.logo|default=''}"></td>
                </tr>
                </thead>
            </table>
            <script>$('[name="logo"]').uploadOneImage()</script>
        </div>

        <div class="layui-form-item block margin-bottom-20 clearBoth">
            <span class="color-green">详情内容</span>
            <style type="text/css">
                .clear {
                    clear: both;
                }
            </style>
            <textarea id="content" type="text/plain" name="content" style="width:100%;height:500px;">{$vo.content|default=''|raw}</textarea>
        </div>

        {if $fieldsList}
        <fieldset class="layui-elem-field layui-field-title">
            <legend>自定义字段</legend>
        </fieldset>
        <div class='layui-form layui-card'>
            {foreach name="fieldsList" item="field"}
            <div class="layui-form-item layui-row layui-col-space15">
                <span class="color-green block">{$field.field_other_name}</span>
                {if $field.filed_type == "text"}
                <input name="{$field.field_name}" class="layui-input" placeholder="请输入{$field.field_other_name}" value="<?=isset($vo[$field['field_name']])?$vo[$field['field_name']]:""?>">
                {elseif $field.filed_type == "radio"}
                {foreach name="field.setting" item="setting"}
                <input type="radio" name="{$field.field_name}" value="{$setting.setting_value}" ignore title="{$setting.setting_name}"
                <?php if(isset($vo[$field['field_name']]) && $vo[$field['field_name']] == $setting['setting_value']){?>checked<?php }?> >
                {/foreach}
                {elseif $field.filed_type == "checkbox"}
                <div class="layui-input-block margin-left-0">
                    <?php
                                        if(isset($vo[$field['field_name']]) && $vo[$field['field_name']]){
                                            $vo[$field['field_name']] = explode("|", $vo[$field['field_name']]);
                                        }
                                    ?>
                    {foreach name="field.setting" item="setting"}
                    <input type="checkbox" name="{$field.field_name}[{$setting.setting_value}]" title="{$setting.setting_name}"
                    <?php if(isset($vo[$field['field_name']]) && in_array($setting['setting_value'],$vo[$field['field_name']])){?>checked="checked"<?php }else{?><?php }?> >
                    {/foreach}
                </div>
                {elseif $field.filed_type == "textarea"}
                <textarea name="{$field.field_name}" class="layui-textarea"  placeholder="请输入{$field.field_other_name}"><?=isset($vo[$field['field_name']])?$vo[$field['field_name']]:""?></textarea>
                {elseif $field.filed_type == "file"}
                <label class="layui-col-xs8 think-form-group-left">
                    <input name="{$field.field_name}" value='<?=isset($vo[$field['field_name']])?$vo[$field['field_name']]:""?>' placeholder="请上传{$field.field_other_name}" class="layui-input">
                </label>
                <a class="layui-col-xs2 layui-btn think-form-group-right" data-file="btn" data-field="{$field.field_name}" data-type="{$field.filed_default_value}">
                    <i class="layui-icon layui-icon-upload"></i> 上传
                </a>
                {elseif $field.filed_type == "files"}
                <table class="layui-table">
                    <thead>
                    <tr>
                        <td class="text-left padding-0">
                            <div class="help-images">
                                <input name="{$field.field_name}" type="hidden" value="<?=isset($vo[$field['field_name']])?$vo[$field['field_name']]:""?>" >
                                <script>
                                    $('input[name="{$field.field_name}"]').uploadMultipleImage();
                                    $('input[name="{$field.field_name}"]').click(function(){
                                        return false;
                                    });
                                </script>
                            </div>
                        </td>
                    </tr>
                    </thead>
                </table>
                {elseif $field.filed_type == "editor"}
                <textarea name="{$field.field_name}" ><?=isset($vo[$field['field_name']])?$vo[$field['field_name']]:""?></textarea>
                <script>
                    window.form.render();

                    require(['ckeditor'], function () {
                        window.createEditor('[name={$field.field_name}]', {height: 300});
                    });

                </script>
                {/if}

            </div>
            {/foreach}
        </div>
        {/if}


        <div class="text-center margin-0 clearBoth">
            {notempty name='vo.id'}<input type="hidden" name="id" value="{$vo.id}">{/notempty}
            <input type="hidden" name="cat_id" value="{$cateId}">
            <button class="layui-btn layui-btn-danger" data-history-back data-confirm="确定要取消编辑吗？" type='button'>取消编辑</button>
            <button class="layui-btn" type="submit">保存数据</button>
        </div>

    </div>
</form>
{/block}

{block name='script'}
<script>
    window.form.render();

    require(['ckeditor'], function () {
        window.createEditor('[name=content]', {height: 300});
    });

</script>
{/block}